<?php
/*
package : adLeeX plugin
Description: This plgin allow to create new post type corso
Version: 1.0
Author: Luca De Cristofano
Author URI: #
License: GPL2
 */


// inizializza quello che serve
function adleex_course_init()
{

	// creazione del posttype
	$labels = array(
		'name' => __('Courses', ADLEEX_DOMAIN),
		'singular_name' => __('Course', ADLEEX_DOMAIN),
		'add_new' => __('Add new course', ADLEEX_DOMAIN),
		'add_new_item' => __('New course', ADLEEX_DOMAIN),
		'edit_item' => __('Edit course', ADLEEX_DOMAIN),
		'new_item' => __('New course', ADLEEX_DOMAIN),
		'all_items' => __('All course', ADLEEX_DOMAIN),
		'view_item' => __('View this course', ADLEEX_DOMAIN),
		'search_items' => __('search courses', ADLEEX_DOMAIN),
		'not_found' => __('Course not found', ADLEEX_DOMAIN),
		'not_found_in_trash' => __('Courses not found in trash', ADLEEX_DOMAIN),
		'parent_item_colon' => '',
		'menu_name' => __('Course', ADLEEX_DOMAIN)
	);

	$args = array(
		'labels' => $labels,
		'public' => true,
		'publicly_queryable' => true,
		'show_ui' => true,
		'show_in_menu' => true,
		'query_var' => true,
		'rewrite' => array(
			'slug' => 'course'
		),
		'capability_type' => array('course', 'courses'),
		'has_archive' => true,
		'map_meta_cap' => true,
		'hierarchical' => true,
		'menu_position' => null,
		'supports' => array(
			'title'
		)
	);

	register_post_type('course', $args);
	
	register_taxonomy_for_object_type('adleex_placing', 'course');
    register_taxonomy_for_object_type('adleex_topic', 'course');
    register_taxonomy_for_object_type('adleex_partner', 'course');
        
}



// serve per gestire i permalink
function adleex_course_rewrite_flush()
{
	adleex_course_init();
	flush_rewrite_rules();
}

function adleex_course_filter_status($statuses)
{
	$new_statuses = array();
	$new_statuses['draft'] = $statuses['draft'];
	$new_statuses['pending'] = $statuses['pending'];
	$new_statuses['approved'] = $statuses['approved'];
	$new_statuses['publish'] = $statuses['publish'];
	$new_statuses['closed'] = $statuses['closed'];
	
	return $new_statuses;
}



// fissa gli hook
function adleex_course_hooks()
{
	register_activation_hook(__FILE__, 'adleex_course_rewrite_flush'); // serve per i permalink
	add_action('init', 'adleex_course_init'); // quando inizializzo la pagina
    add_filter('course_available_statuses','adleex_course_filter_status');
}


adleex_course_hooks();

include('course_extends.php');


?>
